home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / COMMS / C101.ZIP / UUPC11XS.ZIP / LIB / MKDIR.C < prev    next >
C/C++ Source or Header  |  1992-11-27  |  2KB  |  73 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    m k d i r . c                                                   */
  3. /*                                                                    */
  4. /*    Support routines for UUPC/extended                              */
  5. /*                                                                    */
  6. /*    Changes Copyright 1990, 1991 (c) Andrew H. Derbyshire           */
  7. /*                                                                    */
  8. /*    History:                                                        */
  9. /*       21Nov1991 Break out of lib.c                          ahd    */
  10. /*--------------------------------------------------------------------*/
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <time.h>
  16.  
  17. #ifdef __GNUC__
  18. #include <os2.h>
  19. #else
  20. #include <direct.h>
  21. #endif
  22.  
  23.  
  24. /*--------------------------------------------------------------------*/
  25. /*                    UUPC/extended include files                     */
  26. /*--------------------------------------------------------------------*/
  27.  
  28. #include "lib.h"
  29.  
  30. currentfile();
  31.  
  32. /*--------------------------------------------------------------------*/
  33. /*    M K D I R                                                       */
  34. /*                                                                    */
  35. /*    Like mkdir() but create intermediate directories as well        */
  36. /*--------------------------------------------------------------------*/
  37.  
  38. int MKDIR(const char *inpath)
  39. {
  40.    char *cp;
  41.    char *path;
  42.  
  43.    if (*inpath == '\0')
  44.       return 0;
  45.  
  46.    cp = path = normalize(inpath );
  47.  
  48.  
  49. /*--------------------------------------------------------------------*/
  50. /*        See if we need to make any intermediate directories         */
  51. /*--------------------------------------------------------------------*/
  52.  
  53.    cp = path ;
  54.    while ((cp = strchr(cp, '/')) != nil(char)) {
  55.       *cp = '\0';
  56.  
  57. #ifndef __GNUC__
  58.       mkdir(path);
  59. #else
  60.       DosCreateDir( path, 0);
  61. #endif
  62.       *cp = '/';
  63.       cp++;
  64.    }
  65.  
  66. /*--------------------------------------------------------------------*/
  67. /*                           Make last dir                            */
  68. /*--------------------------------------------------------------------*/
  69.  
  70.    return mkdir(inpath);
  71.  
  72. } /*MKDIR*/
  73.